﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class App_Common_UserControls_MiniAddToCart : System.Web.UI.UserControl
{

    public string ItemNumber
    {
        get
        {
            return (string)ViewState["ItemNumber"];
        }
        set
        {
            ViewState["ItemNumber"] = value;
        }
    }

    public string ProductTitle
    {
        get
        {
            return (string)ViewState["ProductTitle"];
        }
        set
        {
            ViewState["ProductTitle"] = value;
        }
    }

    public decimal UnitPrice
    {
        get
        {
            return (decimal)ViewState["UnitPrice"];
        }
        set
        {
            ViewState["UnitPrice"] = value;
        }
    }

    private Asah.SiteWorx.Commerce.ShoppingCart MyShoppingCart
    {
        get
        {
            if (Session["MyCart"] == null)
                Session["MyCart"] = new Asah.SiteWorx.Commerce.ShoppingCart();
            return (Asah.SiteWorx.Commerce.ShoppingCart)Session["MyCart"];
        }
        set
        {
            Session["MyCart"] = value;
        }
    }

    protected void btnAddToCart_Click(object sender, EventArgs e)
    {
        AddToCart();
    }

    private void AddToCart()
    {
        MyShoppingCart.AddToCart(ItemNumber, ProductTitle, 1, UnitPrice);
    }
}
